package bussinessService.impl;

import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;



import domain.vo.DistrictVO;




import domain.vo.queryObject;
import module.BasicArea;
import bussinessService.basicAreaBussinessService;

/**
 * 
* @ClassName: BasicAreaBussinessServiceImpl
* @Description:  系统基本信息的区域业务服务实现类
* @author chenchao
* @date 2013-10-30 上午01:44:28
*
 */
public class BasicAreaBussinessServiceImpl  implements basicAreaBussinessService{


	/* (non-Javadoc)
	 * @see bussinessService.basicbussinessService#countByQueryObject()
	 */
	public int countByQueryObject() {
		// TODO Auto-generated method stub
		return 0;
	}

	/* (non-Javadoc)
	 * @see bussinessService.basicbussinessService#getById(java.lang.String)
	 */
	public BasicArea getById(String id) throws SQLException {
		// TODO Auto-generated method stub
		return basicAreaService.getById(id);
	}

	/* (non-Javadoc)
	 * @see bussinessService.basicbussinessService#merageObject(java.lang.Object)
	 */
	public void merageObject(BasicArea basicarea) throws SQLException {
		if (basicarea.getBha_id() == 0) {
			basicAreaService.insertObject(basicarea);	
		} else {
			basicAreaService.updateObject(basicarea);
		}
		
	}

	public int countByQueryObject(queryObject queryObject) throws SQLException {
		// TODO Auto-generated method stub
		return basicAreaService.countByQueryObject(queryObject);
	}

	public List<DistrictVO> getObjectByQueryObject(queryObject queryObject) throws SQLException {
		List<DistrictVO> tempVOS = new ArrayList<DistrictVO>(); 
		 List<BasicArea> results =  basicAreaService.getObjectByQueryObject(queryObject);
		 for(BasicArea ba : results) {
			 DistrictVO vo = new DistrictVO();
			 vo.setBha_id(ba.getBha_id());
			 vo.setBhaName(ba.getBhaName());
			 vo.setId(ba.getBha_id());
			 vo.setText(ba.getBhaName());
			 vo.setState("closed");
			 tempVOS.add(vo);
		 }
		 return tempVOS;
	}

	/* (non-Javadoc)
	 * @see bussinessService.basicbussinessService#getAll()
	 */

	public List<DistrictVO> getAll() throws SQLException {
		List<DistrictVO> tempVOS = new ArrayList<DistrictVO>(); 
		 List<BasicArea> results =  basicAreaService.getAll();
		 DistrictVO votop = new DistrictVO();
		 votop.setBha_id(-1);
		 votop.setBhaName("区域不限");
		 votop.setSelected(true);
		 tempVOS.add(votop);
		for(BasicArea ba : results) {
			 DistrictVO vo = new DistrictVO();
			 vo.setBha_id(ba.getBha_id());
			 vo.setBhaName(ba.getBhaName());
			 tempVOS.add(vo);
		 }
		return tempVOS;
	}

	/* (non-Javadoc)
	 * @see bussinessService.basicbussinessService#deleteT(int)
	 */

	public void deleteT(int id) throws SQLException {
		// TODO Auto-generated method stub
		
	}

}
